package io.renren.modules.lucky.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.modules.lucky.dao.LuckyMediaConfigDao;
import io.renren.modules.lucky.dto.LuckyMediaConfigDTO;
import io.renren.modules.lucky.entity.LuckyMediaConfigEntity;
import io.renren.modules.lucky.service.LuckyMediaConfigService;
import cn.hutool.core.util.StrUtil;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 招财猫媒体配置
 *
 * @author Liang Pei 
 * @since 1.0.0 2025-01-07
 */
@Service
public class LuckyMediaConfigServiceImpl extends CrudServiceImpl<LuckyMediaConfigDao, LuckyMediaConfigEntity, LuckyMediaConfigDTO> implements LuckyMediaConfigService {

    @Override
    public QueryWrapper<LuckyMediaConfigEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");

        QueryWrapper<LuckyMediaConfigEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(id), "id", id);

        return wrapper;
    }


    @Override
    public LuckyMediaConfigEntity getByMediaId(String mediaId) {
        return baseDao.selectOne(new QueryWrapper<LuckyMediaConfigEntity>().eq("media_id", mediaId));
    }
}